<html>
<title>MPSDK模块依赖及辅助脚本</title>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script src="js/vue.js"/>
    <script>
        var a = "string"
        document.write(a)

    </script>
    <script src="https://nexus.webeyemobi.com/repository/webeye/com/simple/mpsdk/mpsdk/maven-metadata.xml"></script>
</head>
<body>
<div id="app">
    <h1>MPSDK模块依赖及辅助脚本</h1>
    <h3>脚本引用方法：</h3>
    <ul>
        <li v-for="gradle_url in gradle_urls">
            {{gradle_url['label']}}&nbsp;&nbsp;&nbsp;&nbsp;<button @click="copyGradle(gradle_url['url'])">复制内容</button> <br>
            <div>apply from: <a :href="gradle_url['url']">'{{gradle_url['url']}}'</a></div><br/>
        </li>
    </ul>
    <h3>仓库地址：<button @click="copyRepos(repo_urls)">复制内容</button> </h3>
    <ul>
        <li v-for="repo_url in repo_urls">
            {{mergeRepo(repo_url)}}
        </li>
    </ul>
</div>
<script>
    var repo_urls = [
        'http://nexus.webeyemobi.com/repository/maven-public/',
        'https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea',
        'https://artifact.bytedance.com/repository/Volcengine/',
        'https://bitbucket.org/sdkcenter/sdkcenter/raw/release',
        'https://sdk.tapjoy.com',
        'https://jitpack.io',
        'https://s3.amazonaws.com/smaato-sdk-releases/',
        'https://artifacts.applovin.com/android',
        'https://artifactory.verizonmedia.com/artifactory/maven'
    ]
    var gradle_urls = [
        {'index':'0', 'label':'加密脚本', 'url':'https://imgtu.gitee.io/gradle/encrypt-mp.gradle'},
        {'index':'1', 'label':'AAB混淆', 'url':'https://imgtu.gitee.io/gradle/resguard_aab.gradle'},
        {'index':'2', 'label':'APK混淆', 'url':'https://imgtu.gitee.io/gradle/resguard_apk.gradle'}
    ]
    /**
     * 原型：字符串格式化
     * @param args 格式化参数值
     */
    String.prototype.format = function(args) {
        var result = this;
        if (arguments.length < 1) {
            return result;
        }

        var data = arguments; // 如果模板参数是数组
        if (arguments.length == 1 && typeof (args) == "object") {
            // 如果模板参数是对象
            data = args;
        }
        for ( var key in data) {
            var value = data[key];
            if (undefined != value) {
                result = result.replaceAll("\{" + key + "\}", value);
            }
        }
        return result;
    }
    function mergeRepo(url) {
        var ss = "maven {url '{0}'}"
        ss = ss.format(url)
        return ss
    }
    function copyText(content) {
        var copyInput = document.createElement("textarea")
        document.body.appendChild(copyInput)
        copyInput.value = content
        copyInput.setAttribute('readonly', 'readonly')
        copyInput.select()
        document.execCommand('copy')
        copyInput.remove()
        alert("文本已复制 :\n" + content)
    }
    function copyGradle(url) {
        var gradle = "apply from: '" + url + "'"
        copyText(gradle)
    }
    function copyRepos(repo_urls) {
        var copyRepoString = ""
        for (index in repo_urls) {
            copyRepoString += mergeRepo(repo_urls[index])
            if (index < repo_urls.length - 1) {
                copyRepoString += "\n"
            }
        }
        copyText(copyRepoString)
    }
    var app = new Vue({
      el: '#app',
      data: {
        repo_urls:repo_urls,
        gradle_urls:gradle_urls
      },
      method:{
            mergeRepo:mergeRepo,
            copyGradle:copyGradle
      }
    })

</script>
</body>
</html>